package org.elanfox.intellicommunity.biz.entity.resident;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import org.elanfox.intellicommunity.biz.entity.Base2PO;
import org.elanfox.intellicommunity.common.constant.DataConstant;

import javax.persistence.*;
import java.util.List;

/**
 * 组织架构表
 *
 * @author loutianxi
 * @date 2019-12-04
 */
@Entity
@Data
@Table(name = "t_organization")
public class OrganizationPO extends Base2PO {

    /**
     * 组织架构id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "org_id")
    private Integer orgId;
    /**
     * 上级部门id
     */
    @Column(name = "p_org_id")
    private Integer pOrgId;
    /**
     * 部门名称
     */
    @Column(name = "name")
    private String name;
    /**
     * 部门描述
     */
    @Column(name = "description")
    private String description;
    /**
     * 是否启用
     */
    @Column(name = "enable")
    private boolean enable;

    @Column(name = "item_sort")
    private Integer itemSort;

    @Column(name = "del_flag")
    private boolean delFlag = true;

    @OneToMany(mappedBy = "organization")
    @JsonIgnoreProperties("organization")
    private List<WorkerPO> workers;

    public String getEnableStyle() {
        return enable ? DataConstant.GREEN_STYLE : DataConstant.RED_STYLE;
    }

}
